package com.manage.common.oss.convert;

import com.manage.common.oss.config.CloudStorageConfig;
import com.manage.system.api.entity.SysStorageConfig;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author zhangqing
 * @description 对象转换
 */
@Mapper(componentModel = "spring")
public interface StorageConfigCovert {

    StorageConfigCovert INSTANCE = Mappers.getMapper(StorageConfigCovert.class);

    /**
     * 转换七牛配置信息
     *
     * @param sysStorageConfig 实体类
     * @return dto
     */
    @IterableMapping(elementTargetType = CloudStorageConfig.class)
    @Mapping(source = "accessKey", target = "qiniuAccessKey")
    @Mapping(source = "secretKey", target = "qiniuSecretKey")
    @Mapping(source = "domain", target = "qiniuDomain")
    @Mapping(source = "prefix", target = "qiniuPrefix")
    @Mapping(source = "bucketName", target = "qiniuBucketName")
    CloudStorageConfig toQiniuConfig(SysStorageConfig sysStorageConfig);

    /**
     * 转换阿里云配置信息
     *
     * @param sysStorageConfig 实体类
     * @return dto
     */
    @IterableMapping(elementTargetType = CloudStorageConfig.class)
    @Mapping(source = "accessKey", target = "aliyunAccessKeyId")
    @Mapping(source = "secretKey", target = "aliyunAccessKeySecret")
    @Mapping(source = "domain", target = "aliyunDomain")
    @Mapping(source = "prefix", target = "aliyunPrefix")
    @Mapping(source = "bucketName", target = "aliyunBucketName")
    @Mapping(source = "endPoint", target = "aliyunEndPoint")
    CloudStorageConfig toAliyunConfig(SysStorageConfig sysStorageConfig);

    /**
     * 转换阿里云配置信息
     *
     * @param sysStorageConfig 实体类
     * @return dto
     */
    @IterableMapping(elementTargetType = CloudStorageConfig.class)
    @Mapping(source = "accessKey", target = "qcloudSecretId")
    @Mapping(source = "secretKey", target = "qcloudSecretKey")
    @Mapping(source = "domain", target = "qcloudDomain")
    @Mapping(source = "prefix", target = "qcloudPrefix")
    @Mapping(source = "bucketName", target = "qcloudBucketName")
    @Mapping(source = "region", target = "qcloudRegion")
    CloudStorageConfig toQcloudConfig(SysStorageConfig sysStorageConfig);
}
